package tree;

/**
 * @Description 剑指 Offer 55 - I. 二叉树的深度
 * @Author Firenut
 * @Date 2023-01-24 11:27
 */
public class T55_1_maxDepth {
    int maxDepth;
    public int maxDepth(TreeNode root) {
        preorder(root,0);
        return maxDepth;
    }

    void preorder(TreeNode node,int count){
        if(node==null){
            maxDepth=Math.max(maxDepth,count);
            return;
        }
        count++;
        preorder(node.left, count);
        preorder(node.right, count);
    }
}